package mysqlxa;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @Author: admin
 * @Description:
 * @Date: 2018/10/9 8:55
 */

public class ConnectionFactory {
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection(String ip, String db, String user, String password, int port) throws SQLException {
        String url = "jdbc:mysql://" + ip + ":" + port + "/" + db + "?"
                + "user=" + user + "&password=" + password + "&useSSL=false&verifyServerCertificate=false&useUnicode=true&characterEncoding=UTF8&autoReconnect=true";
        return DriverManager.getConnection(url);
    }
}
